<?php

require_once('include_dao.php');


session_start();

if ( !isset($_SESSION['user'])  || $_SESSION['user'] == "" )
{

    if($_POST['username']==""){

        $_SESSION['error']="Please Login";
        header("Location: admin-index.php");

    }else{

		$username = $_POST['username'];
        $password = $_POST['password'];

        $row = DAOFactory::getUserDAO()->queryByLogin($username);

        if(count($row)==0 || $password!=$row[0]->password){
            $_SESSION['error']="Invalid Login/ Password. Try Again.";
            header("Location: admin-index.php");
        }else{
			$_SESSION['user']=$row[0]->login;
		}

    }

}



?>